home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_01_07 / 1n07036a < prev    next >
Text File  |  1990-11-14  |  755b  |  24 lines

  1.  
  2. LISTING 4
  3.  
  4. /* Set up the C asynch event handler for incoming messages */
  5.  
  6. void asynch_handler(int nd)
  7. {
  8.     struct    addr a;                /* Address & port for UDP connection */
  9.     struct    SREGS seg;            /* Save our segment values here */
  10.     char far *fool_msc;            /* Workaround for spurious conversion */
  11.  
  12.     /* setupt network for getting global descriptors */
  13.     segread(&seg);                        /* Get segments... */
  14.     FP_SEG(fool_msc) = seg.cs;              /* Get correct CS value */
  15.     FP_OFF(fool_msc) = (unsigned)respond_to_msg;
  16.     if ((long) net_asynch(nd, NET_AS_RCV, asynch_stub,
  17.             (unsigned long)fool_msc) < 0) {
  18.         pneterror("net_asynch");
  19.         puts("receive: error setting asynch handler");
  20.         net_release(nd);        /* Explicitly free global */
  21.         exit(1);
  22.     }
  23. }
  24.